<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <title>myblog</title>
    <link href="/css/bootstrap.css" rel="stylesheet">
    <style type="text/css">
        .navbar{
            margin-bottom:0;
        }
    </style>


</head>

<body>

<%- include('header') %>

<div class="container">
    <h3 >欢迎您注册我的博客</h3>
<form class="form-horizontal" role="form" action="/frontend/blog/doregister" method="post" enctype="multipart/form-data">

    <div class="form-group">
        <label for="username" class="col-sm-2 control-label">用户名</label>
        <div class="col-sm-10">
            <input type="text" class="form-control" id="username" name="username" placeholder="用户名">
        </div>
    </div>
    <div class="form-group">
        <label for="psd" class="col-sm-2 control-label">密码</label>
        <div class="col-sm-10">
            <input type="password" class="form-control" id="psd" name="psd" placeholder="密码">
        </div>
    </div>
    <div class="form-group">
        <div class="col-sm-offset-2 col-sm-10">
            <div class="checkbox">
                <label>
                    <input type="checkbox">遵守法律法规
                </label>
            </div>
        </div>
    </div>
    <div class="form-group">
        <div class="col-sm-offset-2 col-sm-10">
            <button type="button" id="btn_register" class="btn btn-default">注册</button>
        </div>
    </div>
</form>
</div>


<!-- Placed at the end of the document so the pages load faster -->
<script src="/js/jquery-1.11.3.min.js"></script>
<script src="/js/bootstrap.js"></script>
<script type="text/javascript">
        $("#btn_register").click(function () {
            var username=$('#username').val();
            var psd=$('#psd').val();
            if(username==''){
                alert("请输入用户名");
                $('#username').focus();
                return;
            }
            if(psd==''){
                alert("请输入密码");
                $('#psd').focus();
                return;
            }
            $.post('/frontend/blog/doregister',{
                username:username,
                psd:psd
            },function (result) {
                if(result=="-5"){
                    alert("服务器报错了");
                }else if(result=="-1"){
                    alert("用户名已经存在了");
                }else{
                    alert("注册成功了");
                }
            })
        })
</script>
</body>
</html>
